<template>
	<!-- <Tabbar></Tabbar> -->
</template>
<script>
	// import routingIntercept from '@/permission/index.js'
	import {
		getAuthorization,
		setAuthorization
	} from "@/utils/auth.js"
	import {
		useAccountStore
	} from "@/store/index.js"
	import {
		AuthStateStore
	} from "@/store/authIndex.js"
	import {
		UserInfo
	} from "@/api/person/index.js"
	// await proxy.$get(UserInfo)
	// import Tabbar from '@/components/tabbar/index'
	import {
		getCurrentInstance,
	} from "vue"

	export default {
		onLaunch: function() {
			window.vConsole = new window.VConsole()
			document.title = "媛世界"
		},
		onShow: async function() {
			let store = useAccountStore()
			let AuthStore = AuthStateStore()
			let token = getAuthorization("token")
			let chatListAll = getAuthorization('chatListAll')
			let makeFriendsList = getAuthorization('makeFriendsList')
			let authState = getAuthorization('authState')
			let userInfo = getAuthorization('userInfo')
			if (chatListAll) {
				store.setChatMsg(chatListAll)
			}
			if (makeFriendsList) {
				store.setMakeFriends(makeFriendsList)
			}
			if (authState) {
				// 更新认证状态
				AuthStore.updateState(authState)
			}
			if (userInfo) {
				// 更新用户信息
				AuthStore.updateUserInfo(userInfo)
			}
			if (!token) {
				let phone = getAuthorization("phoneNumber")
				if (phone) {
					uni.navigateTo({
						url: "/pages/login/mobileNumberLogin/index"
					})
				} else {
					uni.navigateTo({
						url: "/pages/login/mobileNumberLogin/index"
					})
				}

			} else {
				let {
					proxy
				} = getCurrentInstance()
				let data = await proxy.$get(UserInfo + getAuthorization('userId'))
				if (data.code == 200) {
					let userInfo = JSON.stringify(data.data)
					setAuthorization("userInfo", userInfo)
				}
			}
		},
		onHide: function() {},
	}
</script>

<style>
	#app {
		width: 100vw;
		height: 100vh;
		background-position: 0 0;
		background-size: 100%;
	}

	body .auth-pup {
		background: none;
		max-width: calc(100vw - var(--van-padding-md) * 4) !important;
	}
</style>
